package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Dynamic;
import com.sk.bilibili.bean.MemberExtend;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.MemberExtendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @author 邵康
* @date 2021/12/11 18:01
*/
@Api(tags = "用户扩展信息API")
@CrossOrigin
@RestController
@RequestMapping("/memberExtend")
public class MemberExtendController {

    @Autowired
    private MemberExtendService memberExtendService;

    @ApiOperation("add")
    @PostMapping("/add")
    public R<Void> add(@RequestBody MemberExtend memberExtend){
        return memberExtendService.add(memberExtend);
    }

    @ApiOperation("delete")
    @GetMapping("/delete")
    public R<Void> delete(Integer id){
        return memberExtendService.delete(id);
    }

    @ApiOperation("更新当前用户的公告")
    @PostMapping("/updateAnnouncement")
    public R<Void> updateAnnouncement(String announcement){
        return memberExtendService.updateAnnouncement(announcement);
    }

    @ApiOperation("page")
    @GetMapping("/page")
    public R<IPage<MemberExtend>> page( @RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer size){
        return memberExtendService.page(page,size);
    }

    @ApiOperation("获取某人的置顶动态  可能为null")
    @GetMapping("/getTopDynamic")
    public R<Dynamic> getTopDynamic(Integer memberId){
        return memberExtendService.getTopDynamic(memberId);
    }

    @ApiOperation("置顶或取消置顶动态  需要对应的 动态id   若动态id为  -1 取消置顶")
    @GetMapping("/topDynamic")
    public R<Void> topDynamic(Integer id){
        return memberExtendService.topDynamic(id);
    }

}
